package com.zhukunri.sp02.service;

import com.zhukunri.sp01.domain.Item;
import com.zhukunri.sp01.service.ItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

//实现ItemService接口
@Service
@Slf4j
public class ItemServiceImpl implements ItemService {


    //根据订单的id获取所有的商品信息
    @Override
    public List<Item> getItems(String orderId) {

        log.info("获取商品列表,orderId="+orderId);

        //直接返回固定的商品列表
        ArrayList<Item> items = new ArrayList<>();
        items.add(new Item(1,"商品1",11) );
        items.add(new Item(2,"商品2",22) );
        items.add(new Item(3,"商品3",33) );
        items.add(new Item(4,"商品4",44) );
        items.add(new Item(5,"商品5",55) );
        items.add(new Item(6,"商品6",66) );

        return items;
    }

    //根据商品信息，减少库存
    @Override
    public void decreaseNumber(List<Item> items) {

        for (Item item : items) {
            log.info("减少库存"+item);
        }
    }
}
